<?php
$fileName = 'randata.txt';
$handle = fopen ( $fileName, "rb" ); // 使用打开模式为r

if(isset($_GET["year"])&&isset($_GET["month"])&&isset($_GET["day"]))//是否存在"id"的参数
{
	$year = $_GET['year'];
	$month = $_GET['month'];
	$day = $_GET['day'];
	
	$t = new DateTime();
	$t->setDate($year, $month, $day);
	$tnow = new DateTime("1900-01-01");
	
	$t_day = $t->diff($tnow);
	$t_day_left = $t_day->days % 906192;
	
	fseek($handle, $t_day_left*5);
	
	$content = fread ( $handle, 4 ); // 读为二进制
	$ran = fread ( $handle, 1 ); // 读为二进制
	fclose ( $handle );
	$dd = 0;
	
	$bytes = array ();
	for($i = 0; $i < strlen($content); $i++){
		$bytes[] = ord($content[$i]);
	}
	
	for($i = 3; $i >=0; $i--){
		$temp =ord($content[$i]);
		$dd = ($dd<<8) + $temp;
		//echo  '['.$temp . ']--';
		//echo $dd . '--';
	}
	
	$bin = sprintf( "%032b",  $dd );
	$ran = sprintf( "%06b",  ord($ran) );;
	/*
	 echo strlen ( $content ) . '--';
	 print_r($bytes);*/
	echo '{ con:"' . $bin .'",pla:"'. $ran .'",note:"'. $t->format('Y-m-d H:i:s'). '--'. $tnow->format('Y-m-d H:i:s'). ' --' . $t_day->days .'"};';
				//echo '{ con:"' . $bin .'",pla:"'. $ran .'"};';

}








